	<style>
		.auth_tree{
				border:0px solid black;
				height: 450px;
				width: 300px;
				margin-left:150px;
				overflow-y:auto;
		}
		table {
			margin: 0px  auto;
		}
	</style>
	<link 	type="text/css"	rel="stylesheet"	href="/assets/css/default.css" />
	<p style="margin:20px">
	     <form id="form1" name="form1" class="easyui-form" method="post" data-options="" action ="">
	    	<table cellpadding="2">

	    		<tr>
	    			<td width="300" >
                       <h2 style="margin-left:150px;"> 用户组：<?php echo $group['name'] ?></h2>
	    		</tr>

	    		<tr>
	    			<td width="300"  >
	    			  		<input type="hidden"  name="id"      value=""  >
	    			  		<input type="hidden"  name="id" id="group_id"    value="<?php echo $group['id'] ?>"  >
	    			  		<div class="auth_tree">
                            	<ul id="auth" class="easyui-tree" data-options="animate:true,checkbox:true"></ul>
                            </div>
                     </td>
	    		</tr>
	    		 <tr >
    			<td   >
       	   				<p style="margin-left:100px;">
       	   				<a href="javascript:void(0)" class="easyui-linkbutton c9" style="width:80%" onclick="submitForm()">提            交</a>
                 </td>
	    	    </tr>

	    	</table>
	    </form>

	    </div>

	  <script>

		 $(function(){

                 var url  = '<?php echo site_url('home/group/get_auth_tree_json')."/".$group['id'] ;?>';
		 	     $('#auth').tree({
                   checkbox:true,
                   url:url,
               });

	      });




		function submitForm(){
		                    var nodes 	= $('#auth').tree('getChecked');
						    var auth 	= new   Array();
						    for(var i=0; i<nodes.length; i++){
						         var node 	  = $('#auth').tree('find', nodes[i].id);
								 var Parent_node =$('#auth').tree('getParent', node.target);
                                 auth.push(nodes[i].id);
             					 if(Parent_node != null) {
	             					 if(!is_in_array(auth,Parent_node.id)){
	  										auth.push(Parent_node.id);
	             					 }
             					 }
						    }
                            var rules = auth.join(",");
							if(rules =="") {
								show_msg("请选择权限");
							}else{
								var id = $("#group_id").val();
			                     $.ajax({
									   type: "POST",
									   url:"<?php echo site_url('home/group/auth');?>",
									   dataType:"json",
									   data:{id:id,auth:rules},
									   success: function(msg){
											 var index = parent.layer.getFrameIndex(window.name);
											  parent.layer.msg(msg.info, {
													    icon: 1,  //1 成功 ,0 失败
													    time: 2000
											  });
											  parent.$("#myframe_35")[0].contentWindow.reload();
											  parent.layer.close(index);
									   }
								});
							}


			}

			function is_in_array(arr,value)
			{
			  for(var i=0;i<arr.length;i++)
			  {
			     if(arr[i]==value)
			      return true;
			  }
			  return false;
			}


	</script>
</body>
</html>